/*
*   ProcessADT.h
*   Authors: Dustin Striplin
*   contains all of the information pertinant to a process
*/
#ifndef PROCESSADT_H
#define PROCESSADT_H

#include "global.h"
#include "Request.h"

typedef struct process_str {
    int proc_type;       // code for process type, e.g. 0=compute, 1=i0, 2=keyboard, etc.
    int no_steps;       // number of time steps before resetting to 0 - number of instructions
    unsigned int pc;             // the pc value for the process.
    int num_requests;    // number of requests that will be generated during the process run
    unsigned int request_index;   //the index of the current request
    RequestPtr * requests;     // an array of requests, each request (e.g. io service) is issued at a specific
                        // time step. These are the synchronous events that result in traps being issued.
                        // this is the program that the process runs.

    void (*destruct)(struct process_str*); //destructor
    RequestPtr(*step)(struct process_str*);
} ProcessStr;


typedef ProcessStr* ProcessPtr;

ProcessPtr processConstructor(int proc_type, int no_steps, int no_requests, RequestPtr* requests); //create a new processADT

RequestPtr processStep(ProcessPtr this);  //cpu calls this, instruction is executed. after x instructions request will be fired

void processDestructor(ProcessPtr this);

#endif
